<template>
  <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
    <el-form-item label="用户名" prop="name">
      <el-input v-model="ruleForm.name"></el-input>
    </el-form-item>
    <el-form-item label="密码" prop="password">
      <el-input type="password" v-model="ruleForm.password"></el-input>
    </el-form-item>

    <!-- 提交按钮   -->
    <el-form-item>
      <el-button type="primary" @click="submitForm('ruleForm')">登陆</el-button>
      <el-button @click="resetForm('ruleForm')">重置</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
  export default {
    name: "indexlogin",
    data() {
      return {
        ruleForm: {
          name: '',
          password: '',
        },
        rules: {//验证校验 进行初始化
          name: [
            {required: true, message: '请输入用户名', trigger: 'blur'},
            {min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur'}
          ],
          password: [
            {required: true, message: '请输入密码', trigger: 'blur'},
            {min: 6, max: 18, message: '长度在 6 到 18 个字符', trigger: 'blur'}
          ],

        }
      }
    },

    methods: {
      submitForm() {
        /*
        这里要和我们的后台进行交互 我们这里就先留着不写
         */
        //1.我们要进行校验 并且进行页面的跳转
        this.$router.push("/home");//跳转到我们的首页(那么我们的首页是什么样子的？？？)
      }
    }
  }
</script>

<style scoped>

</style>
